Skip to content

fix(scripts): replace GNU find -printf with POSIX basename#1484

Open
dknos wants to merge 1 commit intoNVIDIA:mainfrom
dknos:fix/backup-posix-find-1431
Open

fix(scripts): replace GNU find -printf with POSIX basename#1484
dknos wants to merge 1 commit intoNVIDIA:mainfrom
dknos:fix/backup-posix-find-1431

Conversation

@dknos
Copy link
Copy Markdown
Contributor

@dknos dknos commented Apr 5, 2026

Summary

  • Replaces GNU-only find -printf '%f\n' with POSIX-compatible find ... -exec basename {} \;
  • Fixes silent failure on macOS/BSD where -printf is not available

Test plan

  • Run backup-workspace.sh on Linux
  • Verify output matches previous behavior
  • Run shellcheck on the modified script

Fixes #1431

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved restore selection when no timestamp is provided so the most recent available backup is correctly identified and used.
    • Behavior unchanged for preference of newest entry; the process will still fail gracefully if no backups are found.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a7350935-4c08-4ae8-b3db-521db7a247a6

📥 Commits

Reviewing files that changed from the base of the PR and between 069f16a and 0f077aa.

📒 Files selected for processing (1)
  • scripts/backup-workspace.sh
✅ Files skipped from review due to trivial changes (1)
  • scripts/backup-workspace.sh

📝 Walkthrough

Walkthrough

When restoring without a timestamp, the script now extracts backup directory names using find ... -exec basename {} \; instead of find ... -printf '%f\n'; results are still sorted descending and the latest entry is selected, with unchanged failure behavior when none found.

Changes

Cohort / File(s) Summary
Backup script compatibility
scripts/backup-workspace.sh
Replaced GNU-only find -printf '%f\n' with POSIX-compatible find ... -exec basename {} \; in do_restore() when no timestamp is provided; sorting and selection logic preserved.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

I nibble through backup trails at night,
Swapping GNU crumbs for POSIX light.
BSD spots no longer hide,
Backups found with steady stride—🐇
A small hop, the fix feels right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing GNU-specific find -printf with POSIX-compatible basename in a shell script.
Linked Issues check ✅ Passed The PR directly addresses issue #1431 by replacing GNU find -printf with POSIX-compatible find -exec basename, fixing the macOS/BSD compatibility issue.
Out of Scope Changes check ✅ Passed All changes are scoped to the backup-workspace.sh script's do_restore() function and directly address the POSIX compatibility requirement.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@wscurran wscurran added fix Platform: MacOS Support for MacOS labels Apr 6, 2026
@dknos dknos force-pushed the fix/backup-posix-find-1431 branch from 0f1334c to 069f16a Compare April 8, 2026 05:58
…workspace.sh

The -printf flag is GNU-specific and silently fails on macOS/BSD.
Use -exec basename instead for cross-platform compatibility.

Fixes NVIDIA#1431

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Signed-off-by: dknos <rneebo@gmail.com>
@dknos dknos force-pushed the fix/backup-posix-find-1431 branch from 069f16a to 0f077aa Compare April 8, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Platform: MacOS Support for MacOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backup-workspace.sh Uses GNU-Only find -printf — Silently Fails on macOS - IssueFinder - SN 09

2 participants